<?php defined('SEJUJOPEFDNGJSL') or exit('Access denied');?>

<?php
if(empty($_SESSION["checkscode"])||!strstr($_SESSION["checkscode"],'myaddress')){
    $_GET["m"]="myaddress";
    @require(ROOTTHEMETEMP."checkscode.inc.php");
    exit;
}
if(isset($_GET["moid"])){
}
if(isset($_POST["act"]) && $_POST["act"]=='delbank'){
}
if(!isset($_GET['tempadd'])){
?>
    <?php require("topbut.php") ?>
 <div class="panel panel-inverse">
    <div class="panel-heading">
        <h4 class="panel-title">我的收货地址</h4>
    </div>
    <div class="panel-body">
        <div class="table-responsive">
            <table border="0" cellpadding="0" cellspacing="0"  class="table table-striped givetable" align="center">
              <tbody>
                <tr >
                    <th>序号</th>
                    <th>收货地址</th>
                    <th>手机号</th>
                    <th>收货人</th>
                    <th>添加日期</th>
                    <th>操作</th>
                    <th>删除</th>
                </tr>
            <?php
            $sql="select ld_address.id,address,addressname,phone,add_time,province from ld_address left join ld_province on province_id=provinceid where adid='$_userid' order by id desc";
            $db->query($sql);
            $rs=$db->rs;
            $ii=0;

            foreach ($rs as $k => $v) {
              $ii++;

              $serialid=($pagearr[2]-1)*$pagecount+$ii;

            ?>
                <tr>
                    <td><?php echo $serialid?></td>
                    <td><?php echo $v['province'].$v['address'];?></td>
                    <td><?php echo $v['phone']?></td>
                    <td><?php echo $v['addressname']?></td>
                    <td><?php echo formatdate($v['add_time'],1)?></td>
                    <td><form action="" method="post">&nbsp;<?php echo $v["is_default"]?"<span style='color:#f00'>默认</span>":"<a href='".$GLOBALARR["curl"]."&moid=".$v["id"]."' style='text-decoration:underline'>设为默认</a>"?></form></td>
                    <td>
                        <form action="" method="post">
                            <input type="hidden" name="act" value="delbank"/>
                            <input type="hidden" name="deid" value="<?php echo $v['id'] ?>" />
                            <a href="<?php echo $GLOBALARR['curl']?>&tempadd=2&aid=<?php echo $v['id']?>" class="btn btn-sm btn-warning">修改</a>
                        </form>
                    </td>
                </tr>
            <?php
            }
            ?>
              </tbody>
            </table>
        </div>
    </div>
</div>

<?php if($ii==0){?>
<div class="pagediv" style="text-align:center;color:#E47501">--> 暂无数据</div>
<input type="button" name="" onclick="window.location.href='<?php echo $GLOBALARR['curl']?>&tempadd=1'" value="添加" class="btn btn-success" style="float:right">
<?php }?>
<div class="kuangdiv">
<?php ?>



</div>

<?php
}elseif($_GET['tempadd']==2){
?>
<?php require("topbut.php") ?>
<div class="panel panel-inverse">
    <div class="panel-heading">
        <h4 class="panel-title">修改收货地址</h4>
    </div>
    <?php
    $aid=checkstr($_GET['aid']);
    $db->query("select * from ld_address where id=".$aid." and adid=".$_userid."",2);
    $info= $db->rs;
    ?>
    <div class="panel-body">
        <form action="control.php" method="post"  class="form-horizontal">
            <input type="hidden" name="act" value="addressmodif">
            <input type="hidden" name="deid" value="<?php echo $info['id'] ?>" />
            <style type="text/css">
                .mybantable td{padding:5px 0;}
            </style>
             <!-- <div class="form-group">
                <label class="col-md-3 control-label ui-sortable">选择省</label>
                <div class="col-md-9 ui-sortable">
                   <select class="form-control" id="province_id" name="province_id">
                        <option value="0">请选择省</option>
                        <?php
                        $list=get_province();
                        foreach ($list as $k => $v) {
                        ?>
                        <option value="<?php echo $v['provinceid'];?>" <?php if($v['provinceid']==$info['province_id']) echo "selected";?>><?php echo $v['province'];?></option>
                        <?
                        }
                        ?>
                   </select>

                </div>
            </div> -->

            <div class="form-group">
                <label class="col-md-3 control-label ui-sortable">详细地址</label>
                <div class="col-md-9 ui-sortable">
                   <select class="form-control" id="province_id" name="province_id" style="width:160px;float: left;">
                        <option value="0">请选择省</option>
                        <?php
                        $list=get_province();
                        foreach ($list as $k => $v) {
                        ?>
                        <option value="<?php echo $v['provinceid'];?>" <?php if($v['provinceid']==$info['province_id']) echo "selected";?>><?php echo $v['province'];?></option>
                        <?
                        }
                        ?>
                   </select>
                   <input type="text" name="address" id="address" class="form-control width100" value="<?php echo $info['address']?>" style="float: left;width:70%;">
                </div>
                <style type="text/css">
                    @media screen and (max-width:480px) {
                            .width100{
                                width: 100%!important;
                                margin-top: 5px;
                            }
                        }
                </style>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label ui-sortable">手机号</label>
                <div class="col-md-9 ui-sortable">
                    <input type="text" name="phone" id="phone" value="<?php echo $r['phone']?>" class="form-control" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label ui-sortable">收货姓名</label>
                <div class="col-md-9 ui-sortable">
                    <input type="text" name="shname" id="shname" value="<?php echo $info['addressname']?>" class="form-control">
                </div>
            </div>
             <div class="form-group" style="margin-top:10px">
                <label class="col-md-3 control-label ui-sortable">备注</label>
                <div class="col-md-9 ui-sortable">
                    <input type="text" name="beizhu" value="<?php echo $info['beizhu']?>" id="beizhu" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-9 col-md-offset-3 ui-sortable">
                    <button type="submit" class="btn btn-md btn-warning">修改</button>
                    <button type="button" class="btn btn-md btn-info" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>

<?php
}
elseif($_GET['tempadd']==1){
?>
<?php require("topbut.php") ?>
<div class="panel panel-inverse">
    <div class="panel-heading">
        <h4 class="panel-title">添加收货地址</h4>
    </div>
    <div class="panel-body">
        <form action="control.php" method="post"  class="form-horizontal">
            <input type="hidden" name="act" value="addressadd">
            <style type="text/css">
                .mybantable td{padding:5px 0;}
            </style>
            <div class="form-group">
                <label class="col-md-3 control-label ui-sortable">详细地址</label>
                <div class="col-md-9 ui-sortable">
                   <select class="form-control" id="province_id" name="province_id" style="width:160px;float: left;">
                        <option value="0">请选择省</option>
                        <?php
                        $list=get_province();
                        foreach ($list as $k => $v) {
                        ?>
                        <option value="<?php echo $v['provinceid'];?>" <?php if($v['provinceid']==$info['province_id']) echo "selected";?>><?php echo $v['province'];?></option>
                        <?
                        }
                        ?>
                   </select>
                   <input type="text" name="address" id="address" class="form-control width100" value="<?php echo $info['address']?>" style="float: left;width:70%;">
                </div>
                <style type="text/css">
                    @media screen and (max-width:480px) {
                            .width100{
                                width: 100%!important;
                                margin-top: 5px;
                            }
                        }
                </style>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label ui-sortable">手机号</label>
                <div class="col-md-9 ui-sortable">
                    <input type="text" name="phone" id="phone" value="<?php echo $r['phone']?>" class="form-control" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label ui-sortable">收货姓名</label>
                <div class="col-md-9 ui-sortable">
                    <input type="text" name="shname" id="shname" class="form-control">
                </div>
            </div>
             <div class="form-group">
                <label class="col-md-3 control-label ui-sortable">备注</label>
                <div class="col-md-9 ui-sortable">
                    <input type="text" name="beizhu" id="beizhu" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-9 col-md-offset-3 ui-sortable">
                    <button type="submit" class="btn btn-md btn-warning">添加</button>
                    <button type="button" class="btn btn-md btn-info" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>

<?php
}
?>
